package com.int_tech.utils;

import com.int_tech.station.entity.Station;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/1.
 */
public class AreaUtils {

    private static int ONE = 1;

    private static int ZERO = 0;

    public static List<Station> areaHelp(List<Station> stationList) {
        List<Station> list = new ArrayList<>();
        for (Station station : stationList) {
            String[] s = station.getArea().split("&");
            String s1 = "";
            for (int i = ZERO; i <= s.length - ONE; i++) {
                s1 += "(" + s[i] + ");";
            }
            String area = s1.substring(ZERO, s1.length() - ONE);
            station.setArea(area);
            list.add(station);
        }
        return list;
    }

    public static String areaHelps(String area) {
        String[] split = area.split(",");
        String s = "";
        for (int i = 0; i < split.length; i++) {
            if (i % 2 == 0) {
                s += split[i] + ",";
            }else if (i % 2 != 0){
            s += split[i] + "&";
            }
        }
        String substring = s.substring(0,s.length()-1);
        return substring;
    }
}
